package com.osdp.auth.feign;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AuthFeignServiceFallbackFactory implements FallbackFactory<AuthFeignService> {

    private final AuthFeignServiceFallback authFeignServiceFallback;

    public AuthFeignServiceFallbackFactory(AuthFeignServiceFallback authFeignServiceFallback){
        this.authFeignServiceFallback = authFeignServiceFallback;
    }
    @Override
    public AuthFeignServiceFallback create(Throwable throwable) {
        //打印下异常
        if(log.isErrorEnabled()){
            log.error("发生异常:{}",throwable);
        }
        return authFeignServiceFallback;
    }
}
